package com.xb.loan.admin.web.controller;

import com.xb.loan.admin.Constants;
import com.xb.loan.log.exception.BizException;
import com.xb.loan.util.DateHelper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;

@Controller
@RequestMapping("/print")
public class PrintController {
	
    @RequestMapping(value = "printController")
    public String openUpdatePartnerById(HttpServletRequest req, Model model) throws BizException,IOException{
        String printName = java.net.URLDecoder.decode(req.getParameter("printName"),"UTF-8");
        String printTime = DateHelper.DateToString("yyyy年MM月dd日", new Date());
        String hideColumn = req.getParameter("hideColumn");
        String thColumn = req.getParameter("thColumn");
        String flagContext = req.getParameter("flagContext");
        HttpSession session = req.getSession();
        String loginName = (String) session.getAttribute(Constants.SESSION_LOGIN_NAME);
        
        model.addAttribute("printTime", printTime);
        model.addAttribute("loginName", loginName);
        if("context".equals(flagContext)){
            return "common/print_context";
        }else{
            model.addAttribute("printName", printName);
            model.addAttribute("thColumn",thColumn);
            model.addAttribute("hideColumn", hideColumn);
            return "common/print";
        }
    }
}
